var api = require('../../utils/api.js');
var app = getApp();
Page({
    data: {
        newcode:'',
        dates:[],
        msgcount:0,
        noteid:0
    },
    currentPageNumber: 1,
    onLoad() {
        this.getdatelist();
    },

    getdatelist(){
        

        var that=this;
        api.post({
            url: 'date/getdatelist',
            data: '',
            success: data => {
                that.setData({
                    dates:data.data,

                })
            }
        })


    },
    onShow() {
        let user = wx.getStorageSync('user');
        if (!user) {
            wx.navigateTo({
                url: '/pages/login/index'
            });
        }

        var that=this;
        api.post({
            url: 'user/getmymessage',
            data: '',
            success: data => {
                that.setData({
                    msgcount:data.data,
                    noteid:data.msg,
                })
            }
        })

    },

    seenote(){
        var noteid=this.data.noteid;
        if(noteid>0){
            wx.navigateTo({
              url: '/pages/note/info?id='+noteid
            })
        }


    },

    notedown(){
      wx.navigateTo({
        url: '/pages/note/index',
      })
    },
   

    seelist(){
        wx.switchTab({
        url: '/pages/list/index',
        })
    },
    previewImage(e) {
        wx.previewImage({
            current: '', // 当前显示图片的http链接
            urls: [e.currentTarget.dataset.previewUrl] // 需要预览的图片http链接列表
        });

    },
    onShareAppMessage() {
        return {
            title: '好玩的,都在这儿~~',
            path: '/pages/index/index'
        }
    },

    scanCodeEvent: function(){
        var that = this;
        wx.scanCode({
          onlyFromCamera: true,// 只允许从相机扫码
          success(res){
            JSON.stringify(res)
            console.log(res.result)
            
            wx.navigateTo({
              url: '/pages/about/update?code='+res.result,
            })
     
          },
          fail(res){
            JSON.stringify(res)
            console.log(res.result)
          }
        })
      },
    

      //查询信息
      getvode(ret){
        console.log(ret);

        if(!ret.detail.value){
            return false;
        }  

        wx.navigateTo({
          url: '/pages/about/update?code='+ret.detail.value,
        })

      },

      getcodetit(ret){
    
        if(!ret.detail.value){
            return false;
        }  

        this.setData({
            newcode:ret.detail.value
        })

      },

        //查询信息
        getcodes(ret){
            var value=this.data.newcode;
            wx.navigateTo({
              url: '/pages/about/update?code='+value,
            })
    
          },

      nextrl(ret){``
        console.log(ret);
        wx.navigateTo({
          url: ret.currentTarget.dataset.url,
        })
      },

      logidng(){

        wx.showToast({
          title: '开发中...',
          icon:'none'
        })

      },
      seevideo(){
        wx.navigateTo({
          url: '/pages/car/index',
        })
      },
      seelogs(){
          wx.navigateTo({
            url: '/pages/index/logs',
          })
      }

    
    
    });
